﻿package {
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.display.Loader;
	import flash.net.URLLoader; 
	import flash.events.*;
	import flash.events.IOErrorEvent;


	public class SlideMenu extends MovieClip {
		var tx:Number;
		var ty:Number;
		var tz:Number;
		var angle:Number;
		var radius:uint;
		
		var skills:SimpleButton = new skillsBtn()
		var skillTab:MovieClip = new skillsPane();
		var skillBtn:SimpleButton = new skillsBtn();
		var floor:MovieClip = new floorPaneMC();
		var gameTab:MovieClip = new gamesPane();
		var PopuBoxgrey:MovieClip = new PopupBoxgreyPane();
		var PopuBoxblue:MovieClip = new PopupBoxbluePane();
		var PopuBoxgreen:MovieClip = new PopupBoxgreenPane();
		var gameBtn:SimpleButton = new gamesBtn();
		var profileTab:MovieClip = new profilePane();
		var magrey:MovieClip = new mathgreyPane();
		var magreen:MovieClip = new mathgreenPane();
		var mablue:MovieClip = new mathbluePane();
		var pgrey:MovieClip = new phygreyPane();
		var pgreen:MovieClip = new phygreenPane();
		var pblue:MovieClip = new phybluePane();
		var cgrey:MovieClip = new comgreyPane();
		var cgreen:MovieClip = new comgreenPane();
		var cblue:MovieClip = new combluePane();
		var mat:MovieClip = new mathinllusPane();
		var phys:MovieClip = new phyinllusPane();
		var comp:MovieClip = new cominllusPane();
		var profBtn:SimpleButton = new profileBtn();
		
		var bg:MovieClip = new backgroundMC();
		var phygreyBtn:SimpleButton = new physicsgreyBtn();
		var phygreenBtn:SimpleButton = new physicsgreenBtn();
		var phyblueBtn:SimpleButton  = new physicsblueBtn();
		var magreenBtn:SimpleButton = new mathgreenBtn();
		var magreyBtn:SimpleButton = new mathgreyBtn();
		var mablueBtn:SimpleButton = new mathblueBtn();
		var compgreyBtn:SimpleButton = new computersciencegreyBtn();
		var compgreenBtn:SimpleButton = new computersciencegreenBtn();
		var compblueBtn:SimpleButton = new computerscienceblueBtn();
		
		var phgreyBtn:SimpleButton = new physgreyBtn();
		var phgreenBtn:SimpleButton = new physgreenBtn();
		var phblueBtn:SimpleButton = new physblueBtn();
		var msgreyBtn:SimpleButton = new mathmgreyBtn();
		var msgreenBtn:SimpleButton = new mathmgreenBtn();
		var msblueBtn:SimpleButton = new mathmblueBtn();
		var cogreyBtn:SimpleButton = new computgreyBtn();
		var cogreenBtn:SimpleButton = new computgreenBtn();
		var coblueBtn:SimpleButton = new computblueBtn();
		
		var shopBtn:SimpleButton = new shoppingBtn();
		var casBtn:SimpleButton = new caselBtn();
		
		
		//var shopBtn:SimpleButton = new shoppingchartBtn;
		public function SlideMenu() {

			addChild(bg);
			addChild(floor);
			addChild(skillTab);
			addChild(profileTab);
			addChild(gameTab);
			addChild(gameBtn);
			addChild(skillBtn);
			addChild(profBtn);
			addChild(phygreyBtn);
			addChild(phygreenBtn);
			addChild(phyblueBtn);
			addChild(magreenBtn);
			addChild(magreyBtn);
			addChild(mablueBtn);
			addChild(compgreyBtn);
			addChild(compgreenBtn);
			addChild(compblueBtn);
			addChild(skills);
			addChild(casBtn);
			addChild(PopuBoxgrey);
			addChild(PopuBoxgreen);
			addChild(PopuBoxblue);
			addChild(pgrey);
			addChild(pblue);
			addChild(pgreen);
			addChild(phys);
			addChild(phgreyBtn);
			addChild(phgreenBtn);
			addChild(shopBtn);
			addChild(magrey);
			addChild(magreen);
			addChild(mablue);
			addChild(cgrey);
			addChild(cgreen);
			addChild(cblue);
			addChild(phblueBtn);
			addChild(msgreyBtn);
			addChild(msblueBtn);
			addChild(msgreenBtn);
			addChild(cogreyBtn);
			addChild(cogreenBtn);
			addChild(coblueBtn);
			addChild(casBtn);
			addChild(mat);
			addChild(comp);
			reset();
			
			
			skills.rotation = -90
			skills.y = 0+ skills.height
			skills.x = stage.stageWidth/2 - skills.width/2
			
			

			profBtn.scaleX=.3;
			profBtn.scaleY = .3;
			
			skillBtn.scaleX=.3;
			skillBtn.scaleY = .3;
			
			gameBtn.scaleX=.3;
			gameBtn.scaleY = .3;
			
			phygreyBtn.x=stage.stageWidth/2 - (phygreyBtn.width - 30);
			phygreyBtn.y = stage.stageHeight/2 - (phygreyBtn.height + 20);
			
		
			
			phyblueBtn.x = phygreyBtn.x;
			phyblueBtn.y = phygreyBtn.y + phygreyBtn.height + 40;
			
			
			phygreenBtn.x = phygreyBtn.x;
			phygreenBtn.y = phyblueBtn.y + phyblueBtn.height + 40;
			
			magreyBtn.x = phygreyBtn.x + phygreyBtn.width + 150;
			magreyBtn.y = phygreyBtn.y;
			
			mablueBtn.x = magreyBtn.x;
			mablueBtn.y = phyblueBtn.y;

			magreenBtn.x = magreyBtn.x;
			magreenBtn.y = phygreenBtn.y;
			
			compgreyBtn.x = magreyBtn.x + magreyBtn.width + 150;
			compgreyBtn.y = phygreyBtn.y;
			
			compblueBtn.x = compgreyBtn.x;
			compblueBtn.y = phyblueBtn.y;

			compgreenBtn.x = compgreyBtn.x;
			compgreenBtn.y = phygreenBtn.y;
			PopuBoxgrey.x = phygreyBtn.x - 300;
			PopuBoxgrey.y = phygreyBtn.y - 90;
			PopuBoxgreen.x = PopuBoxgrey.x;
			PopuBoxgreen.y = PopuBoxgrey.y;
			PopuBoxblue.x = PopuBoxgrey.x;
			PopuBoxblue.y = PopuBoxgrey.y;
			
			
				
				
			pgrey.x = PopuBoxgrey.x + 30;
			pgrey.y = PopuBoxgrey.x + 90;
			pblue.x = pgrey.x;
			pblue.y = pgrey.y;
			magrey.x = pgrey.x;
			magrey.y = pgrey.y
			magreen.x = pgrey.x;
			magreen.y = pgrey.y;
			mablue.x = pblue.x;
			mablue.y = pblue.y;
			cgrey.x = pgrey.x;
			cgrey.y = pgrey.y;
			cgreen.x = pgrey.x;
			cgreen.y = pgrey.y;
			cblue.x = pgrey.x;
			cblue.y = pgrey.y;
			phys.x = PopuBoxgrey.x + 10;
			phys.y = PopuBoxgrey.y + 280;
				
			phgreyBtn.x = PopuBoxgrey.x -30;
			phgreyBtn.y = PopuBoxgrey.y -30;
			phblueBtn.x = PopuBoxblue.x -30;
			phblueBtn.y = PopuBoxblue.x -30;
			msgreyBtn.x = PopuBoxgrey.x -30;
			msgreyBtn.y = PopuBoxgrey.x -30;
			msblueBtn.x = PopuBoxgrey.x -30;
			msblueBtn.y = PopuBoxgrey.x -30;
			msgreenBtn.x= PopuBoxgrey.x -30;
			msgreenBtn.y= PopuBoxgrey.x -30;
			cogreyBtn.x = PopuBoxgrey.x -30;
			cogreyBtn.y = PopuBoxgrey.x -30;
			cogreenBtn.x = PopuBoxgrey.x -30;
			cogreenBtn.y = PopuBoxgrey.x -30;
			coblueBtn.x = PopuBoxgrey.x -30;
			coblueBtn.y = PopuBoxgrey.x -30;
			
			
				
				
			casBtn.x = PopuBoxgrey.x + 250 ;
			casBtn.y = PopuBoxgrey.y +380;
				
			shopBtn.x = PopuBoxgrey.x + 290 ;
			shopBtn.y = PopuBoxgrey.y +380;
				
			PopuBoxgreen.x = phygreyBtn.x -300 ;
			PopuBoxgreen.y = phygreyBtn.y -90;
				
				
			pgreen.x = PopuBoxgreen.x + 30;
			pgreen.y = PopuBoxgreen.x + 90;
				
			phys.x = PopuBoxgreen.x + 10;
			phys.y = PopuBoxgreen.y + 280;
				
			phgreenBtn.x = PopuBoxgreen.x -30;
			phgreenBtn.y = PopuBoxgreen.y -30;
			
			mat.x = PopuBoxgreen.x + 10;
			mat.y = PopuBoxgreen.y + 280;
			comp.x = PopuBoxgrey.x + 10;
			comp.y = PopuBoxgrey.y + 280;

			skillTab.height=profBtn.height*3;
			profileTab.height=profBtn.height*3;
			gameTab.height = profBtn.height * 3;
			floor.y=stage.stageHeight-floor.height;
			initialPositions()
			profBtn.addEventListener(MouseEvent.CLICK, mouseClickProfile);
			skillBtn.addEventListener(MouseEvent.CLICK, mouseClickSkill);
			gameBtn.addEventListener(MouseEvent.CLICK, mouseClickGame);
			phygreyBtn.addEventListener(MouseEvent.CLICK, mouseClickphygrey);
			phygreenBtn.addEventListener(MouseEvent.CLICK, mouseClickphygreen);
			phyblueBtn.addEventListener(MouseEvent.CLICK, mouseClickphyblue);
			
			magreyBtn.addEventListener(MouseEvent.CLICK, mouseClickmagrey);
			magreenBtn.addEventListener(MouseEvent.CLICK, mouseClickmagreen);
			mablueBtn.addEventListener(MouseEvent.CLICK, mouseClickmablue);
			
			compgreyBtn.addEventListener(MouseEvent.CLICK, mouseClickcompgrey);
			compgreenBtn.addEventListener(MouseEvent.CLICK, mouseClickcompgreen);
			compblueBtn.addEventListener(MouseEvent.CLICK, mouseClickcompblue);
			
			phgreyBtn.addEventListener(MouseEvent.CLICK, mouseClickphygrey);
			phgreenBtn.addEventListener(MouseEvent.CLICK, mouseClickphygreen);
			phblueBtn.addEventListener(MouseEvent.CLICK , mouseClickphyblue);
			
			msgreyBtn.addEventListener(MouseEvent.CLICK , mouseClickmagrey);
			msgreenBtn.addEventListener(MouseEvent.CLICK , mouseClickmagreen);
			msblueBtn.addEventListener(MouseEvent.CLICK , mouseClickmablue);
			
			cogreyBtn.addEventListener(MouseEvent.CLICK , mouseClickcompgrey);
			cogreenBtn.addEventListener(MouseEvent.CLICK , mouseClickcompgreen);
			coblueBtn.addEventListener(MouseEvent.CLICK , mouseClickcompblue);
			
			shopBtn.addEventListener(MouseEvent.CLICK , mouseCLickshopping);
			casBtn.addEventListener(MouseEvent.CLICK , mouseCLickcasel);
		}
			

		public function mouseClickProfile(Evt:MouseEvent):void {
			if (! profileTab.visible) {
				profBtn.x=profileTab.x+profileTab.width;
				skillBtn.x=0;
				gameBtn.x=0;
				skillTab.visible=false;
				profileTab.visible=true;
				gameTab.visible=false;
			} else {
				profBtn.x=0;
				profileTab.visible=false;
			}

		}
		
		public function mouseClickSkill(Evt:MouseEvent):void {
			if (! skillTab.visible) {
				skillBtn.x=skillTab.x+skillTab.width;
				profBtn.x=0;
				gameBtn.x=0;
				skillTab.visible=true;
				profileTab.visible=false;
				gameTab.visible=false;
			} else {
				skillBtn.x=0;
				skillTab.visible=false;
			}

		}
		public function mouseClickGame(Evt:MouseEvent):void {
			if (! gameTab.visible) {
				skillBtn.x=0;
				profBtn.x=0;
				gameBtn.x=gameTab.x+gameTab.width;
				skillTab.visible=false;
				profileTab.visible=false;
				gameTab.visible=true;
			} else {
				gameBtn.x=0;
				gameTab.visible=false;
			}

		}
		
		public function onError(e:IOErrorEvent){
                        trace("");
		}
		
		
		public function mouseClickphygrey(Evt:MouseEvent) :void {
			if(PopuBoxgrey.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgrey.visible = true
				pgrey.visible = true
				phys.visible = true
				phgreyBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
		
		}
		public function mouseClickphygreen(Evt:MouseEvent) :void {
			if(PopuBoxgreen.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgreen.visible = true
				pgreen.visible = true
				phys.visible = true
				phgreenBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
		}
		public function mouseClickphyblue(Evt:MouseEvent) :void {
			if(PopuBoxblue.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxblue.visible = true
				pblue.visible = true
				phys.visible = true
				phblueBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		public function mouseClickmagrey(Evt:MouseEvent) :void {
			if(PopuBoxgrey.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgrey.visible = true
				magrey.visible = true
				mat.visible = true
				msgreyBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		public function mouseClickmagreen(Evt:MouseEvent) :void {
				if(PopuBoxgreen.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgreen.visible = true
				magreen.visible = true
				mat.visible = true
				msgreenBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		public function mouseClickmablue(Evt:MouseEvent) :void {
				if(PopuBoxblue.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxblue.visible = true
				mablue.visible = true
				mat.visible = true
				msblueBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		
		public function mouseClickcompgrey(Evt:MouseEvent) :void {
				if(PopuBoxgrey.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgrey.visible = true
				cgrey.visible = true
				comp.visible = true
				cogreyBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		public function mouseClickcompgreen(Evt:MouseEvent) :void {
				if(PopuBoxgreen.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxgreen.visible = true
				cgreen.visible = true
				comp.visible = true
				cogreenBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		public function mouseClickcompblue(Evt:MouseEvent) :void {
			  if(PopuBoxblue.visible)
			{
				reset()
			}
			else
			{
				reset()
				PopuBoxblue.visible = true
				cblue.visible = true
				comp.visible = true
				coblueBtn.visible = true
				casBtn.visible = true
				shopBtn.visible = true
			}
			
		}
		
		
		
		
		
		public function mouseCLickshopping(Evt:MouseEvent ):void {
			
		}
		public function mouseCLickcasel(Evt:MouseEvent ):void {
			
		}
		public function initialPositions():void {
			profBtn.x=0;
			gameBtn.x=0;
			skillBtn.x=0;
			profBtn.y = stage.stageHeight / 2 - (profBtn.height + 100);
			skillBtn.y=profBtn.y+profBtn.height;
			gameBtn.y = skillBtn.y + skillBtn.height;
			skillTab.x=0-profBtn.width;
			skillTab.y=profBtn.y;
			skillTab.visible = false;
			profileTab.x=0-profBtn.width;
			profileTab.y=profBtn.y;
			profileTab.visible = false;
			gameTab.x=0-profBtn.width;
			gameTab.y=profBtn.y;
			gameTab.visible = false;
			
			
		}
	
		public function reset():void {
			phgreenBtn.visible = false;
			phblueBtn.visible = false;
			
			phgreyBtn.visible = false;
			msgreyBtn.visible = false;
			msgreenBtn.visible = false;
			msblueBtn.visible = false;
			cogreyBtn.visible = false;
			cogreenBtn.visible = false;
			coblueBtn.visible = false;
			PopuBoxblue.visible = false;
			PopuBoxgrey.visible = false;
			PopuBoxgreen.visible = false;
			pblue.visible = false;
			pgrey.visible = false;
			pgreen.visible = false;
			magrey.visible = false;
			magreen.visible = false;
			mablue.visible = false;
			cgrey.visible = false;
			cgreen.visible = false;
			cblue.visible = false;
			casBtn.visible = false;
			shopBtn.visible = false;
			mat.visible = false;
			phys.visible = false;
			comp.visible = false;
		}
	}
}